﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DataInfo;
using KenLib.BusinessManager;
using System.Drawing;
using System.Web.UI.MobileControls;
using System.Web.Services;
using System.Collections.Generic;


public partial class JOINT_frmJ_TraineeLangAbilityInput : System.Web.UI.Page
{
    private int? currentId = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        ((JOINT_MstPage_JOINT)this.Master).changeTitle("入学情報（語学力）登録");
        ((JOINT_MstPage_JOINT)this.Master).HideLiArea("input");

        if (Session["役"] == null || Session["役"].ToString() == "")
        {
            Response.Redirect("~/frmD_Login.aspx");
        }
        if (Session["ID"] == null)
        {
            Response.Redirect("frmJ_TraineeEnterSchoolSearch.aspx");
        }
        if (!IsPostBack)
        {

            ShowGrid();
            this.getDD1_語学名();
            this.getDDL_検定種別コード();
            this.DataColumnView();
        }
        ddl語学名.Focus();
        btn_終了.Enabled = false;
        //Error
        validateddl_語学名.ErrorMessage = GetError("ER00001");
        validatetxtレベル.ErrorMessage = GetError("ER00001");
        validateddl_検定種別.ErrorMessage = GetError("ER00001");
        validate_txtスコスListening.ErrorMessage = GetError("ER00001");
        CustomValidator2.ErrorMessage = GetError("ER00002");
        validate_txtスコスwriting.ErrorMessage = GetError("ER00001");
        CustomValidator4.ErrorMessage = GetError("ER00002");
        validate_txtスコスreading.ErrorMessage = GetError("ER00001");
        CustomValidator5.ErrorMessage = GetError("ER00002");
        validatetxt_検定受験日.ErrorMessage = GetError("ER00001");
        CustomValidator6.ErrorMessage = GetError("ER00006");
        CustomValidator1.ErrorMessage = GetError("ER00005");
        CustomValidator3.ErrorMessage = GetError("ER00009");
        CustomValidator7.ErrorMessage = GetError("ER00002");
        CustomValidator8.ErrorMessage = GetError("ER00002");
        CustomValidator9.ErrorMessage = GetError("ER00002");
        //check session
        if (Session["終了Status"] == null)
        {
            Session.Add("終了Status", false);
            btn_終了.Enabled = (bool)Session["終了Status"];
        }
    }
    protected void btn_保有資格情報へ_Click(object sender, EventArgs e)
    {
        List<List<String>> list = new List<List<String>>();
        String[] varList = Request.Form.AllKeys;
        for (int i = 1; i < varList.Length; i++)
        {
            string controlName = varList[i];
            string value = Request.Params.Get(controlName).Replace("<", "&lt;");
            value = value.Replace(">", "&gt;");
            string serverControlName = controlName.Replace("ctl00$ContentPlaceHolder1$", "");
            List<String> val = new List<String>();
            val.Add(serverControlName);
            val.Add(value);
            list.Add(val);
        }

        Session["listValue"] = list;
        Response.Redirect("frmJ_TraineeDiplomaInput.aspx");
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    protected void btn_終了_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable dt = (DataTable)ViewState["CurrentTable"];
            DataView dv = new DataView(dt);
            dv.Sort = "ID DESC";
            //dv.Sort = "IsInit";

            語学力情報Manager tns = new 語学力情報Manager();
            if (ViewState["CurrentTable1"] != null)
            {
                foreach (DataRow dataRow1 in dv.Table.Rows)
                {
                    int id = Int32.Parse(dataRow1["IsInit"].ToString());
                    if (id == 0 || id == 1)
                    {
                        int 語学コード = Int32.Parse(dataRow1["語学コード"].ToString());
                        string 語学名 = dataRow1["語学名"].ToString();
                        string レベル = dataRow1["レベル"].ToString();
                        int 検定種別コード = Int32.Parse(dataRow1["検定種別コード"].ToString());
                        string 検定種別 = dataRow1["検定種別"].ToString();
                        DateTime 検定受験日 = DateTime.Parse(dataRow1["検定受験日"].ToString());
                        int スコスListening = Int32.Parse(dataRow1["スコスListening"].ToString());
                        int スコスWriting = Int32.Parse(dataRow1["スコスWriting"].ToString());
                        int スコスReading = Int32.Parse(dataRow1["スコスReading"].ToString());
                        int スコスTotal = Int32.Parse(dataRow1["スコスTotal"].ToString());
                        int 社員ID = Int32.Parse(Session["ID"].ToString());
                        語学力情報 oj = new 語学力情報();
                        oj.語学コード1 = 語学コード;
                        oj.語学名 = 語学名;
                        oj.レベル = レベル;
                        oj.検定種別コード1 = 検定種別コード;
                        oj.検定種別 = 検定種別;
                        oj.検定受験日 = 検定受験日;
                        oj.スコスListening = スコスListening;
                        oj.スコスWriting = スコスWriting;
                        oj.スコスReading = スコスReading;
                        oj.スコスTotal = スコスTotal;
                        oj.社員ID = 社員ID;
                        oj.廃止区分 = 0;
                        tns.Insert_frmJ_TraineeLangAbilityInput(oj);
                    }
                    if (id == 2 && Session["Array"] != null)
                    {
                        List<String> myAl1 = (List<String>)Session["Array"];
                        foreach (string str in myAl1)
                        {
                            int temp = Int32.Parse(dataRow1["ID"].ToString());
                            if (Int32.Parse(str) == temp)
                            {
                                int 語学コード = Int32.Parse(dataRow1["語学コード"].ToString());
                                string 語学名 = dataRow1["語学名"].ToString();
                                string レベル = dataRow1["レベル"].ToString();
                                int 検定種別コード = Int32.Parse(dataRow1["検定種別コード"].ToString());
                                string 検定種別 = dataRow1["検定種別"].ToString();
                                DateTime 検定受験日 = DateTime.Parse(dataRow1["検定受験日"].ToString());
                                int スコスListening = Int32.Parse(dataRow1["スコスListening"].ToString());
                                int スコスWriting = Int32.Parse(dataRow1["スコスWriting"].ToString());
                                int スコスReading = Int32.Parse(dataRow1["スコスReading"].ToString());
                                int スコスTotal = Int32.Parse(dataRow1["スコスTotal"].ToString());
                                語学力情報 ui = new 語学力情報();
                                ui.語学コード1 = 語学コード;
                                ui.語学名 = 語学名;
                                ui.レベル = レベル;
                                ui.検定種別コード1 = 検定種別コード;
                                ui.検定種別 = 検定種別;
                                ui.検定受験日 = 検定受験日;
                                ui.スコスListening = スコスListening;
                                ui.スコスWriting = スコスWriting;
                                ui.スコスReading = スコスReading;
                                ui.スコスTotal = スコスTotal;
                                ui.ID = temp;
                                tns.Update_Update_frmJ_TraineeLangAbilityInput(ui);
                            }
                        }
                    }
                }
                Session.Add("終了Status", null);
            }
            this.ShowGrid();
            dt.Rows.Clear();
            btn_終了.Enabled = false;
            Session.Remove("Array");

        }
        catch { }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    /// <summary>
    /// BIND DATA INTO DROPDOWNLIST (DD1_語学名)
    /// </summary>
    public void getDD1_語学名()
    {
        語学コードManager frm = new 語学コードManager();
        DataTable dt = new DataTable();
        dt = frm.Select_DDLTraineeLangAbilityInput();
        if (dt.Rows.Count > 0)
        {
            ddl語学名.DataSource = dt;
            ddl語学名.DataTextField = "語学名";
            ddl語学名.DataValueField = "ID";
            ddl語学名.DataBind();

            ListItem 選択 = new ListItem("[選択]", "-1");
            ddl語学名.Items.Insert(0, 選択);
        }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    /// <summary>
    /// BIND GRIDVIEW INTO DROPDOWNLIST(DDL_検定種別コード)
    /// </summary>
    public void getDDL_検定種別コード()
    {
        検定種別コードManager frm = new 検定種別コードManager();
        DataTable dt = new DataTable();
        dt = frm.Select_DDL検定種別コードTraineeLangAbilityInput();
        if (dt.Rows.Count > 0)
        {
            ddl検定種別.DataSource = dt;
            ddl検定種別.DataTextField = "検定種別";
            ddl検定種別.DataValueField = "検定種別コード";
            ddl検定種別.DataBind();

            ListItem 選択 = new ListItem("[選択]", "-1");
            ddl検定種別.Items.Insert(0, 選択);

        }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    /// <summary>
    /// BIND DATA INTO GRIDVIEW
    /// </summary>
    public void ShowGrid()
    {
        int 社員ID = Int32.Parse(Session["ID"].ToString());
        DataTable dt = new DataTable();
        語学力情報Manager frm = new 語学力情報Manager();
        dt = frm.ShowGrid語学力情報(社員ID);
        DataColumn col = new DataColumn();
        col.DataType = System.Type.GetType("System.Int32");
        col.ColumnName = "IsInit";
        dt.Columns.Add(col);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["IsInit"] = "3";
        }


        if (dt.Rows.Count > 0)
        {
            grv1.Visible = false;
            grv.Visible = true;
            grv.DataSource = dt;
            ViewState["CurrentTable"] = dt;
            grv.DataBind();
        }
        else
        {
            grv1.Visible = true;
            grv.Visible = false;
            grv.DataSource = dt;
            ViewState["CurrentTable"] = dt;
            AppCode_Common.ShowEmtyGrid<本社履歴>(grv1, 6, "データがありません。", "");
        }
    }
    public void DataColumnView()
    {
        try
        {
            DataTable dtv = new DataTable();
            DataColumn col;

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.Int32");
            col.ColumnName = "語学コード";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.String");
            col.ColumnName = "語学名";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.String");
            col.ColumnName = "レベル";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.Int32");
            col.ColumnName = "検定種別コード";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.String");
            col.ColumnName = "検定種別";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.DateTime");
            col.ColumnName = "検定受験日";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.Int32");
            col.ColumnName = "スコスListening";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.Int32");
            col.ColumnName = "スコスWriting";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.Int32");
            col.ColumnName = "スコスReading";
            dtv.Columns.Add(col);

            col = new DataColumn();
            col.DataType = System.Type.GetType("System.Int32");
            col.ColumnName = "スコスTotal";
            dtv.Columns.Add(col);

            ViewState["CurrentTable1"] = dtv;
        }
        catch { }
    }
    /// <summary>
    /// Add new row for gridview
    /// </summary>
    protected void AddNewRow()
    {
        try
        {
            if (ViewState["CurrentTable"] != null)
            {
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                DataRow drCurrentRow = null;
                grv1.Visible = false;
                grv.Visible = true;
                drCurrentRow = dtCurrentTable.NewRow();

                drCurrentRow["語学コード"] = ddl語学名.SelectedValue.ToString();
                drCurrentRow["語学名"] = ddl語学名.SelectedItem.ToString();
                drCurrentRow["レベル"] = HttpUtility.HtmlEncode(txtレベル.Text.ToString().Trim());
                drCurrentRow["検定種別コード"] = ddl検定種別.SelectedValue.ToString();
                drCurrentRow["検定種別"] = ddl検定種別.SelectedItem.ToString();
                drCurrentRow["検定受験日"] = txt_検定受験日.Text.ToString();
                drCurrentRow["スコスListening"] = txtスコスListening.Text.ToString().Trim();
                drCurrentRow["スコスWriting"] = txtスコスwriting.Text.ToString().Trim();
                drCurrentRow["スコスReading"] = txtスコスreading.Text.ToString().Trim();

                var rPoint = int.Parse(txtスコスListening.Text.ToString().Trim());
                var lPoint = int.Parse(txtスコスwriting.Text.ToString().Trim());
                var wPoint = int.Parse(txtスコスreading.Text.ToString().Trim());
                drCurrentRow["スコスTotal"] = rPoint + lPoint + wPoint;

                drCurrentRow["IsInit"] = "0";
                dtCurrentTable.Rows.Add(drCurrentRow);

                DataView dv = new DataView(dtCurrentTable);
                dv.Sort = "IsInit";
                ViewState["CurrentTable"] = dv.ToTable();
                grv.DataSource = dv;
                grv.DataBind();
                Session.Add("終了Status", true);
            }

        }
        catch (Exception e) { }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    public void DataCurrentTable()
    {
        try
        {
            if (ViewState["CurrentTable"] != null)
            {
                DataTable dt = (DataTable)ViewState["CurrentTable1"];
                grv1.Visible = false;
                grv.Visible = true;
                DataRow drCurrentRow = null;

                drCurrentRow = dt.NewRow();
                //drCurrentRow["語学名"] = ddl語学名.Text.ToString();
                drCurrentRow["語学コード"] = ddl語学名.SelectedValue.ToString();
                drCurrentRow["語学名"] = ddl語学名.SelectedItem.ToString();
                drCurrentRow["レベル"] = HttpUtility.HtmlEncode(txtレベル.Text.ToString().Trim());
                drCurrentRow["検定種別コード"] = ddl検定種別.SelectedValue.ToString();
                drCurrentRow["検定種別"] = ddl検定種別.SelectedItem.ToString();
                //drCurrentRow["検定種別コード"] = ddl検定種別.SelectedValue.ToString();
                drCurrentRow["検定受験日"] = txt_検定受験日.Text.ToString();
                drCurrentRow["スコスListening"] = txtスコスListening.Text.ToString().Trim();
                drCurrentRow["スコスWriting"] = txtスコスwriting.Text.ToString().Trim();
                drCurrentRow["スコスReading"] = txtスコスreading.Text.ToString().Trim();
                drCurrentRow["スコスTotal"] = txtスコスtotal.Text.ToString().Trim();

                ViewState["CurrentTable1"] = dt;

            }

        }
        catch { }
    }

    protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)// to mau 
    {
        if (e.Row.RowIndex != -1)
        {
            e.Row.Attributes.Add("ondblclick", "javascript:__doPostBack('ctl00$ContentPlaceHolder1$grv','doubleClick$" + e.Row.RowIndex + "')");
            int ID = Int32.Parse(e.Row.Cells[7].Text);
            if (ID == 0 || ID == 1)
            {
                e.Row.CssClass = "insert";
                //e.Row.ForeColor = System.Drawing.Color.Maroon;
            }
            if (ID == 2)
            {
                e.Row.CssClass = "update";
                //e.Row.BackColor = System.Drawing.Color.Chocolate;
                //e.Row.ForeColor = System.Drawing.Color.Maroon;
            }

        }
    }
    /// <summary>
    /// EVENT'S BUTTON 次登録
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_次登録_Click(object sender, EventArgs e)
    {
        try
        {
            CustomValidator3.Validate();
            if (!CustomValidator3.IsValid) return;

            btn_終了.Enabled = true;
            AddNewRow();
            DataCurrentTable();
            if (Page.IsValid)
                ResetForm();
            else
                ShowGrid();
        }
        catch (Exception) { }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }

    public int CheckID(string id1, string id2)
    {
        if (id1 == id2)
            return 1;
        return 0;
    }

    protected void btn_更新_Click(object sender, EventArgs e)
    {

        CustomValidator3.Validate();
        if (!CustomValidator3.IsValid) return;
        try
        {
            btn_次登録.Visible = true;
            btn_更新.Visible = false;


            string id = Session["temp"].ToString();
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
            foreach (DataRow row1 in dtCurrentTable.Rows)
            {

                int IDtam = Int32.Parse(row1["ID"].ToString());
                if (Int32.Parse(id) == IDtam)
                {
                    row1["語学コード"] = ddl語学名.SelectedValue.ToString();
                    row1["語学名"] = ddl語学名.SelectedItem.Text.ToString();
                    row1["レベル"] = HttpUtility.HtmlEncode(txtレベル.Text.ToString().Trim());
                    row1["検定種別コード"] = ddl検定種別.SelectedValue.ToString();
                    row1["検定種別"] = ddl検定種別.SelectedItem.ToString();
                    row1["検定受験日"] = txt_検定受験日.Text.Trim().ToString();
                    row1["スコスListening"] = txtスコスListening.Text.Trim().ToString();
                    row1["スコスWriting"] = txtスコスwriting.Text.Trim().ToString();
                    row1["スコスReading"] = txtスコスreading.Text.Trim().ToString();
                    var rPoint = int.Parse(txtスコスListening.Text.ToString().Trim());
                    var lPoint = int.Parse(txtスコスwriting.Text.ToString().Trim());
                    var wPoint = int.Parse(txtスコスreading.Text.ToString().Trim());
                    row1["スコスTotal"] = rPoint + lPoint + wPoint;

                    if (row1["IsInit"].ToString() == "3")
                    {
                        row1["IsInit"] = "2";
                    }
                    if (row1["IsInit"].ToString() == "0")
                    {
                        row1["IsInit"] = "1";
                    }

                }
            }
            //ViewState["CurrentTable"] = dtCurrentTable;
            DataView dv = new DataView(dtCurrentTable);
            ViewState["CurrentTable"] = dtCurrentTable;
            //dv.Sort = "ID DESC";
            dv.Sort = "IsInit";
            ViewState["CurrentTable"] = dv.ToTable();
            grv.DataSource = dv;
            grv.DataBind();
            btn_終了.Enabled = true;
            ResetForm();
            Session.Add("currentId", null);
        }
        catch { }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    /// <summary>
    /// RESET FORM
    /// </summary>
    public void ResetForm()
    {
        ddl語学名.SelectedIndex = 0;
        txtレベル.Text = "";
        ddl検定種別.SelectedIndex = 0;
        txt_検定受験日.Text = "";
        txtスコスListening.Text = "";
        txtスコスwriting.Text = "";
        txtスコスreading.Text = "";
        txtスコスtotal.Text = "";

    }
    protected void btn_キャンセル_Click(object sender, EventArgs e)
    {
        Response.Redirect("frmJ_TraineeEnterSchoolSearch.aspx");
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }

    protected void btn_リセット_Click(object sender, EventArgs e)
    {
        ResetForm();
    }
    /// <summary>
    /// EVENT CLICK INTO GRIDVIEW
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ItemView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName.Equals("doubleClick"))
            {
                string ID = grv.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString(); //Int32.Parse((e.CommandArgument).ToString());
                Session["temp"] = ID.ToString();
                System.Collections.Generic.List<String> myAL = new List<string>();
                if (Session["Array"] != null)
                {
                    myAL = (System.Collections.Generic.List<String>)Session["Array"];
                }
                myAL.Add(ID.ToString());
                Session["Array"] = myAL;
                DataTable dt = (DataTable)ViewState["CurrentTable"];
                foreach (DataRow dataRow1 in dt.Rows)
                {
                    string IDtam = (dataRow1["ID"].ToString());
                    if (ID == IDtam)
                    {

                        ddl語学名.SelectedValue = dataRow1["語学コード"].ToString();
                        Session.Add("currentId", dataRow1["語学コード"].ToString());
                        txtレベル.Text = dataRow1["レベル"].ToString().Trim();
                        ddl検定種別.SelectedValue = dataRow1["検定種別コード"].ToString();
                        String date = dataRow1["検定受験日"].ToString();
                        DateTime time = DateTime.Parse(date);
                        date = time.ToString("yyyy/MM/dd");
                        txt_検定受験日.Text = date;
                        txtスコスListening.Text = dataRow1["スコスListening"].ToString();
                        txtスコスwriting.Text = dataRow1["スコスWriting"].ToString();
                        txtスコスreading.Text = dataRow1["スコスReading"].ToString();
                        txtスコスtotal.Text = dataRow1["スコスTotal"].ToString();

                    }
                }

                btn_更新.Visible = true;
                btn_次登録.Visible = false;
                Session.Add("終了Status", true);
            }
        }
        catch { }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }
    /// <summary>
    /// GET ERROR MESSAGE
    /// </summary>
    /// <param name="errorid"></param>
    /// <returns></returns>
    public String GetError(string errorid) // ham dung de lay ma loi hien thi thong tin cua loi do.
    {
        Error er = new Error();
        er.ErrorID = errorid;
        ErrorManager frm_error = new ErrorManager();
        DataTable dt = frm_error.getError(er);
        return dt.Rows[0][2].ToString();
    }
    protected void grv_PageIndexChanging(object sender, GridViewPageEventArgs e)// phan trang.
    {
        grv.PageIndex = e.NewPageIndex;
        DataTable dt = (DataTable)ViewState["CurrentTable"];
        DataView dv = new DataView(dt);
        dv.Sort = "ID DESC";
        grv.DataSource = dv;
        grv.DataSource = dt;
        grv.DataBind();
    }

    protected void CustomValidator3_ServerValidate(object source, ServerValidateEventArgs args)
    {
        //Kiem tra trung id ///////////////////////////////////////////////////////////////
        if (btn_更新.Visible == true)
        {
            string selectId = ddl語学名.SelectedValue.ToString();
            var currentId = Session["currentId"].ToString();
            if (!selectId.Equals(currentId))
            {
                args.IsValid = true;
                int subId = Int32.Parse(ddl語学名.SelectedValue.ToString());
                DataTable dt = (DataTable)ViewState["CurrentTable"];

                foreach (DataRow row in dt.Rows)
                {
                    int id2 = int.Parse(row["語学コード"].ToString());
                    if (subId == id2)
                    {
                        args.IsValid = false;
                    }
                }
            }
        }
        else
        {
            args.IsValid = true;
            int subId = Int32.Parse(ddl語学名.SelectedValue.ToString());
            DataTable dt = (DataTable)ViewState["CurrentTable"];

            foreach (DataRow row in dt.Rows)
            {
                int id2 = int.Parse(row["語学コード"].ToString());
                if (subId == id2)
                {
                    args.IsValid = false;
                }
            }
        }
        if (args.IsValid == false)
        {
            int lPoint = 0;
            if (txtスコスListening.Text.Trim().Length > 0)
                lPoint = int.Parse(txtスコスListening.Text);

            int rPoint = 0;
            if (txtスコスreading.Text.Trim().Length > 0)
                rPoint = int.Parse(txtスコスreading.Text);

            int wPoint = 0;
            if (txtスコスwriting.Text.Trim().Length > 0)
                wPoint = int.Parse(txtスコスwriting.Text);


            if (txtスコスListening.Text != "" && txtスコスreading.Text != "" && txtスコスwriting.Text != "")
            {
                txtスコスtotal.Text = (lPoint + rPoint + wPoint).ToString();
            }
        }
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
        /////////////////////////////////////////////////////////////////////////////////////
    }
    protected void txtスコスListening_TextChanged(object sender, EventArgs e)
    {
        string reading = txtスコスreading.Text;
        string listening = txtスコスListening.Text;
        string writing = txtスコスwriting.Text;

        if (reading.Trim().Length == 0) reading = "0";
        if (listening.Trim().Length == 0) listening = "0";
        if (writing.Trim().Length == 0) writing = "0";

        int rPoint = int.Parse(reading);
        int wPoint = int.Parse(writing);
        int lPoint = int.Parse(listening);

        int total = wPoint + rPoint + lPoint;

        txtスコスtotal.Text = total.ToString();
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "regis", "startup();", true);
    }

}



